VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} frmTextPassword 
   Caption         =   "Database Connection"
   ClientHeight    =   3840
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   5985
   OleObjectBlob   =   "frmTextPassword.frx":0000
   StartUpPosition =   1  'CenterOwner
End
Attribute VB_Name = "frmTextPassword"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' version 7.7
' frmTextPassword functions
' Copyright 2011 potato.peelings@gmail.com



Private boolWasClosed As Boolean
Private boolNoScreenRefresh As Boolean
Private strUserName As String
Private strPassword As String


' clear retained values
Public Sub sClearRetainFlag()
    CheckBox1.Value = False
End Sub


' get values
Function fGetTextPassword(strCaption, Optional boolMainProgram, Optional boolParamNoScreenRefresh)
On Error GoTo Error_Handler
    
    ' it it's missing it was not called from the main program
    If IsMissing(boolMainProgram) Then
        boolMainProgram = False
    End If
    
    ' skip screen update?
    If IsMissing(boolParamNoScreenRefresh) Then
        boolNoScreenRefresh = False
    Else
        boolNoScreenRefresh = boolParamNoScreenRefresh
    End If
    
    
    ' retain functionality is only for the main program
    If Not boolMainProgram Then
        CheckBox1.Visible = False
    Else
        CheckBox1.Visible = True
    
        ' just return the values if already retained
        If CheckBox1.Value Then
            fGetTextPassword = strUserName & Chr(13) & strPassword
            Exit Function
        End If
    End If
    
    
    ' set the form caption and show the form
    Caption = strCaption
    boolWasClosed = False
    If Not boolNoScreenRefresh Then
        Application.ScreenUpdating = True
    End If
    Call ExcelBricks.sPauseClock
    Call txtTextbox.SetFocus
    Show
    Call ExcelBricks.sContinueClock
    Application.ScreenUpdating = False

    If boolWasClosed Then
        ExcelBricks.strGlobalErrDescription = "Authentication cancelled. Ending run."
        Err.Raise ExcelBricks.lngShowGlobal
    End If
    
    ' return value
    fGetTextPassword = txtTextbox & Chr(13) & txtPassword
    
    ' store values to retain
    If boolMainProgram And CheckBox1.Value Then
        strUserName = txtTextbox
        strPassword = txtPassword
    End If
    
    ' clear the form
    txtTextbox = ""
    txtPassword = ""

Error_Handler:
    If Err.Number <> 0 Then Err.Raise Err.Number, , Err.Description
End Function


' submit data
Private Sub btnSubmit_Click()
    Me.Hide
    
    ' force a screen update
    If Not boolNoScreenRefresh Then
        Application.ScreenUpdating = True
    End If
End Sub


' when closed
Private Sub UserForm_Terminate()
    boolWasClosed = True
End Sub
